<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //立即执行函数两种写法  (function() {} )()  (function() {} ())
        (function (a, b) {
            console.log('1.和为:', a + b);
            var num = 10;
        })(4, 5);

        (function sum(a, b) {
            console.log('2.和为:', a + b);
            var num = 10;
        }(45, 78))
        
        //2.立即执行函数最大作用:创建了一个作用域，里面的所有变量都是局部变量，不会有命名冲突的问题

    </script>
</body>

</html>